Ext.define('MyApp.view.user.UserForm', {
	extend: 'Ext.window.Window',
	alias: 'widget.userForm',
	initComponent: function(){
		Ext.apply(this, {
			layout: 'column',
			autoScroll: true,
			modal: true,//遮盖
			title : '增加新用户',
			maximizable: true,//最大化
			resizable: false,
			items: [{
				xtype: 'form',
				bodyPadding: 10,//内边距
				defaultType: 'textfield',
				fieldDefaults: {
					allowBlank: false,//不允许为空
					anchor: '100%',
					afterLabelTextTpl: Ext.myUtil.required,
					labelAlign: 'right',//标签在右边
					msgTarget: 'side',
					labelWidth: 120//标签长度，
					
				},
				items: [{
						name: 'userName',
						emptyText : '输入用户名称,不能为空',
						fieldLabel: '用户名'
					},{
						name: 'loginID',
						fieldLabel: '登陆ID',
						validateOnChange:false,
						vtype:'alphanum',
						validator: function(value) {
							  var msg = true;
							  var record = this.up('form').getRecord();
							  if(!(record&&record.get('loginID')==value)){
							  	 Ext.Ajax.request({
								    url: 'user/chackUserLoginId',
								    params: {
								        loginId: value
								    },
								    async :  false,//同步请求数据
								    success: function(response){
								        var text = response.responseText;
								        if(text!=''){
								        	msg = false;
								        }
								    }
								});
							  }
							return msg?true:'登陆名已存在';
				        }
					},/*{
						name: 'password',
						inputType: 'password',
						fieldLabel: '密码'
					},{
						name: 'repassword',
						inputType: 'password',
						fieldLabel: '再次输入密码',
						validator: function(value) {
				                var password = this.previousSibling('[name=password]');
				                return (value === password.getValue()) ? true : '两次密码不一致';
				        }
					},*/{
							xtype:'radiogroup',
							fieldLabel : '是否活动',
							vertical: true,
	            			items: [{
			                    boxLabel  : '是',
			                    name      : 'active',
			                    inputValue: true
			                },{
			                    boxLabel  : '否',
			                    name      : 'active',
			                    checked:true,
			                    inputValue: false
			                }]
					},{
						//xtype: 'datetimefield',
						xtype:'timefield',
						name: 'createDate',
						fieldLabel: '创建日期',
						format: 'Y-m-d', 
						disabled : true,
						value: new Date()
	                }
				]
			}],
			buttonAlign: 'center',
			buttons: [{
				text: '保存',
				itemId: 'save',
				glyph:0xf0c7
			},{
				text: '取消',
				itemId: 'cancel',
				glyph:0xf00d
			}]
		});
		this.callParent(arguments);
	}
});